CLASS zupdate_pr_sche DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    INTERFACES if_oo_adt_classrun .
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS ZUPDATE_PR_SCHE IMPLEMENTATION.


  METHOD if_oo_adt_classrun~main.

*-- Read existing Schedule Line data
    READ ENTITY I_SchedgLineTP_2
      ALL FIELDS WITH VALUE #(
                        ( %key-SchedulingAgreement        = '5500000004'
                          %key-SchedulingAgreementItem    = '00010'
                          %key-ScheduleLine               = '0189' ) )
      RESULT DATA(lt_schd_line).

*-- Update ScheduleLineOrderQuantity field, for example
    DATA: lt_schedline_update TYPE TABLE FOR UPDATE I_SchedgLineTP_2.

    APPEND INITIAL LINE TO lt_schedline_update ASSIGNING FIELD-SYMBOL(<ls_schedline_upd>).
    <ls_schedline_upd>                                    = CORRESPONDING #(  lt_schd_line[ 1 ] ).
    <ls_schedline_upd>-ScheduleLineOrderQuantity          = 260.
    <ls_schedline_upd>-%control-ScheduleLineOrderQuantity = if_abap_behv=>mk-on.

    MODIFY ENTITIES OF I_SchedgAgrmtHdrTP_2
      ENTITY PurSchedgAgrmtItmScheduleLine
        UPDATE FROM lt_schedline_update
      FAILED DATA(ls_failed)
      REPORTED DATA(ls_reported).

    COMMIT ENTITIES
      RESPONSE OF I_SchedgAgrmtHdrTP_2
        FAILED DATA(ls_failed_late)
        REPORTED DATA(ls_reported_late).


    CLEAR:lt_schedline_update.
*-- Read existing Schedule Line data
    READ ENTITY I_SchedgLineTP_2
      ALL FIELDS WITH VALUE #(
                        ( %key-SchedulingAgreement        = '5500000002'
                          %key-SchedulingAgreementItem    = '00080'
                          %key-ScheduleLine               = '0004' ) )
      RESULT DATA(lt_schd_line_2).



    APPEND INITIAL LINE TO lt_schedline_update ASSIGNING <ls_schedline_upd>.
    <ls_schedline_upd>                                    = CORRESPONDING #(  lt_schd_line_2[ 1 ] ).
    <ls_schedline_upd>-ScheduleLineOrderQuantity          = 600.
    <ls_schedline_upd>-%control-ScheduleLineOrderQuantity = if_abap_behv=>mk-on.

    MODIFY ENTITIES OF I_SchedgAgrmtHdrTP_2
      ENTITY PurSchedgAgrmtItmScheduleLine
        UPDATE FROM lt_schedline_update
      FAILED DATA(ls_failed_2)
      REPORTED DATA(ls_reported_2).
    COMMIT ENTITIES
RESPONSE OF I_SchedgAgrmtHdrTP_2
  FAILED DATA(ls_failed_late_2)
  REPORTED DATA(ls_reported_late_2).
  ENDMETHOD.
ENDCLASS.
